package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.model.wemedia.pojos.WmMaterial;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile) throws IOException {

        ResponseResult result=wmMaterialService.upload(multipartFile);
        return result;
    }

    /**查询所有素材
     * | 接口路径 | /api/v1/material/list |
     * | 请求方式 | POST                  |
     * | 参数     | WmMaterialDto         |
     * | 响应结果 | ResponseResult        |
     */
    @PostMapping("list")
    public ResponseResult getList(@RequestBody WmMaterialDto wmMaterialDto){

        ResponseResult result=wmMaterialService.getList(wmMaterialDto);

        return result;
    }


}
